BatteryStatus
BatteryStatus Get status of battery charger and voltage level
#include <Power.h> Power Manager
OSErr BatteryStatus(Status, Power);
Byte *Status internal battery status (see below)
Byte *Power power value (see below)
returns 0 = noErr
The BatteryStatus function returns the status of the battery charger and
the voltage level of the battery. The bits in the Status parameter are defined as
follows:
Bit Meaning
7 Reserved.
6 Reserved.
5 The charger connection has or has not changed state. If 1, the charger
has been recently connected or dis connected.
4 The battery warning. If 1, the battery voltage is low.
3 The dead battery indicator. This bit is always 0.
2 The hicharge counter overflow. If 1, the hicharge counter has
overflowed.
1 The charge rate. If 1, the battery is charging at the hicharge rate.
0 The charger is or is not connected. If 1, the charger is connected.
The Power Manager monitors the voltage level of the internal battery and
warns the user when the voltage drops below a threshold value stored in
parameter RAM. If the voltage continues to drop and falls below an other, lower
value stored in parameter RAM, the Power Manager puts the computer into
the sleep state. The Power Manager provides a function that allows you to
read the state of charge of the battery and the status of the battery charger.
You can use the constants shown Power Mgr Data to check the values of
these bits.
Use the following formula to calculate the battery voltage, where Power is
the value of the Power parameter returned by this function:
voltage = ((Power/100) + 5.12) volts
Due to the nature of lead-acid batteries, the battery power remaining is
difficult to measure accurately. Temperature, load, and other factors can alter
the measured voltage by 30 percent or more. The Power Manager takes as
many of these factors into account as possible, but the voltage measurement can
still be in error by up to 10 percent. The measurement is most accurate when
the Macintosh Portable has been in the sleep state for at least 30 minutes.
When the battery charger is connected to a Macintosh Portable computer with
a low battery, the battery is charged at the hicharge rate (1.5 amps) until
battery voltage reaches 7.2 volts. The Power Manager has a counter (the
hicharge counter) that measures the time required to raise the battery
voltage to this level.
After the 7.2 volt level is reached, the power management circuits maintain
the hicharge connection until the hicharge counter counts down to 0. This
ensures that the battery is fully charged. At the end of that time, the power
management circuits supply the battery with just enough current to replace the
voltage lost through self-discharge. When the hicharge counter has overflowed,
it indicates that the charging circuit is having trouble charging the battery.
Bit 5 is set when the charger connection is changed-either connected or
dis connected. When this bit is set, the Power Manager sends an interrupt to
the CPU.
The battery warning bit (bit 4) is set whenever battery voltage drops below
the value set in parameter RAM. The Power Manager sends an interrupt to
the CPU once every second when battery voltage is low.
If bit 3 were set, it would indicate a dead battery; however, the
Power Manager automatically shuts the system down when the battery
voltage drops below a preset level, so this bit is always 0.